<?php
/**
 * 任务小应用
 * (c)2010-2099
 */

!defined('Q_PATH') && exit;

class TaskModel extends Model{

	static public function init__(){
		return array(
			'table_name'=>'task',
			'autofill'=>array(
				array('task_is_completed',0,'create'),
			),
			'check'=>array(
				'task_subject'=>array(
					array('require','任务主题不能为空'),
					array('max_length',200,'任务主题不能超过 200 个字符'),
				),
				'task_description'=>array(
					array('require','任务描述不能为空'),
				),
			),
		);
	}

	static function F(){
		$arrArgs=func_get_args();
		return ModelMeta::instance(__CLASS__)->findByArgs($arrArgs);
	}

	static function M(){
		return ModelMeta::instance(__CLASS__);
	}

	protected function beforeSave_(){
		$this->task_subject=C::text($this->task_subject);
		$this->task_description=C::cleanJs($this->task_description);
	}

	public function completed($nCompleted){
		$nCompleted=(int)$nCompleted;
		$this->changeProp('task_is_completed',$nCompleted);
		return $this;
	}

}

